package study.HL7;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.parser.PipeParser;

/**
 * @Author 刘伟涛
 * @Date 2024/8/6 14:16
 **/
public class TestParse {
    public static void main(String[] args) throws HL7Exception {
        String hl7Message = "MSH|^~\\&|HIS|RIH|EKG|EKG|202108051200||ADT^A01|0001|P|2.3\r"
                + "PID|||12345^^^RIH^MR||Doe^John||19800101|M|||123 Main St^^Metro^NY^12345||555-1234|||\r";

        PipeParser parser = new PipeParser();
        Message message = parser.parse(hl7Message);

/*        if (message instanceof ADT_A01) {
            ADT_A01 adt = (ADT_A01) message;
            PID pid = adt.getPID();
            System.out.println("Patient Name: " + pid.getPatientName(0).getFamilyName().getValue()
                    + ", " + pid.getPatientName(0).getGivenName().getValue());
        }*/
    }
}
